package main.userInterface;

import javax.swing.*;
import javax.swing.table.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Graphics.*;
import javax.swing.event.*;

import main.userInterface.panels.IslandEditorPanel;


/**
 * This class brings together the many parts
 * 
 * @author Gabe
 * @version 01.01
 */
public class GUIFrame extends JFrame{
	
    IslandEditorPanel islandEditPanel;
    //CritterPanel critterEditPanel;
    RunPanel runPanel;
    

	public GUIFrame(){
        super("DEMON - Darwinian Evolution Modeled On Nodes");
        setSize(900,600);
        setResizable(true);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        //RunIO runIO = new RunIO(this);
        
        //Welcome Pane
        JPanel welcomePanel = new JPanel();
        JLabel title = new JLabel("Welcome to DEMON");
        title.setFont(new Font("Serif", Font.PLAIN, 14));
        welcomePanel.add(title);
        JTextArea about = new JTextArea("lotsa helpful info");
        welcomePanel.add(about);
        
        islandEditPanel = new IslandEditorPanel();
        //critterEditPanel = new CritterPanel(runIO);
        //runPanel = new RunPanel();
        
        JTabbedPane contentTabPane = new JTabbedPane();
        contentTabPane.addTab("Welcome", null, welcomePanel,"Welcome to the critter island!");
        contentTabPane.addTab("HexIsland Editor", null, islandEditPanel,"Edits the island.");
        //contentTabPane.addTab("Critter Editor", null, critterEditPanel,"Edits the critters.");
        //contentTabPane.addTab("Run HexIsland", null, runPanel,"Shows the island and runs.");
        add(contentTabPane);
        
        //House Keeping
        //validateTree();
        //pack();
        setVisible(true);
        toFront();
        

        contentTabPane.addChangeListener(new ChangeListener(){ 
            public void stateChanged(ChangeEvent evt){
                //islandEditPanel.updateFileView();
                //critterEditPanel.updateFileView();
                //runPanel.updateFileView();
            }   
        });
    }

    /* private JMenuBar createMenuBar(){
        JMenuBar menuBar = new JMenuBar();
        JMenu menu, submenu; JMenuItem menuItem;
        menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_F); menuBar.add(menu);
        menuItem = new JMenuItem("New",KeyEvent.VK_N); menuItem.setActionCommand("110"); menuItem.addActionListener(this); menu.add(menuItem);
        menuItem = new JMenuItem("Load",KeyEvent.VK_L); menuItem.setActionCommand("120"); menuItem.addActionListener(this); menu.add(menuItem);
        menuItem = new JMenuItem("Save",KeyEvent.VK_S); menuItem.setActionCommand("130"); menuItem.addActionListener(this); menu.add(menuItem);
        menuItem = new JMenuItem("Save as...",KeyEvent.VK_A); menuItem.setActionCommand("140"); menuItem.addActionListener(this);menu.add(menuItem);
        menu.addSeparator();
        menuItem = new JMenuItem("Quit",KeyEvent.VK_Q); menu.add(menuItem);
        menu = new JMenu("Tools"); menu.setMnemonic(KeyEvent.VK_T); menuBar.add(menu);
        /*submenu = new JMenu("Critters Options"); submenu.setMnemonic(KeyEvent.VK_C);
        menuItem = new JMenuItem("Generate Critters",KeyEvent.VK_C); menuItem.setActionCommand("221"); menuItem.addActionListener(this); submenu.add(menuItem);
        menuItem = new JMenuItem("Inspect Critters",KeyEvent.VK_R); menuItem.setActionCommand("222"); menuItem.addActionListener(this); submenu.add(menuItem);
        submenu.addSeparator();
        menuItem = new JMenuItem("Kill Critters",KeyEvent.VK_K); menuItem.setActionCommand("223"); menuItem.addActionListener(this); submenu.add(menuItem);
        menu.add(submenu);*/
        /*menuItem = new JMenuItem("Build Terrain",KeyEvent.VK_C); menuItem.setActionCommand("220"); menuItem.addActionListener(this); menu.add(menuItem);
        menuItem = new JMenuItem("Inspect Critters",KeyEvent.VK_C); menuItem.setActionCommand("230"); menuItem.addActionListener(this); menu.add(menuItem);
        menu.addSeparator();
        menuItem = new JMenuItem("Program Settings",KeyEvent.VK_S); menuItem.setActionCommand("240"); menuItem.addActionListener(this); menu.add(menuItem);
        menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); menuBar.add(menu);
        menuItem = new JMenuItem("Help Files",KeyEvent.VK_H); menuItem.setActionCommand("310"); menuItem.addActionListener(this); menu.add(menuItem);
        menuItem = new JMenuItem("About DEMON",KeyEvent.VK_A);menuItem.setActionCommand("320"); menuItem.addActionListener(this); menu.add(menuItem);
        return menuBar;
    }*/

    public void aboutDemon(){
        JOptionPane.showMessageDialog(null,"DEMON V3.0\n"+
            "Demon was developed in java by Gabe as a not for profit project.\n"+
            "Contact the creator on twitter @ReynardineFox.");
    }

    public static void main(String args[]) throws Exception {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        GUIFrame thegui = new GUIFrame();
    }
}
